package com.xgq.drink.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@TableName("role")
public class Role implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    private String name;        // 角色名称
    private String code;        // 角色编码
    private String description; // 角色描述
    private Integer status;     // 状态：0-禁用，1-启用
    private LocalDateTime createTime;
    private LocalDateTime updateTime;

    @Override
    public String toString() {
        return String.format("%d:%s:%s:%d", id, name, code, status);
    }

    public static Role fromString(String str) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        String[] parts = str.split(":");
        if (parts.length != 4) {
            return null;
        }
        Role role = new Role();
        role.setId(Long.parseLong(parts[0]));
        role.setName(parts[1]);
        role.setCode(parts[2]);
        role.setStatus(Integer.parseInt(parts[3]));
        return role;
    }
} 